package com.liuboya.dao.weibo.users.dao.Impl;

import com.google.common.base.Preconditions;
import com.liuboya.dao.weibo.users.dao.UsersDao;
import com.liuboya.dao.weibo.users.entity.Users;
import com.liuboya.dao.weibo.users.entity.UsersExample;
import com.liuboya.dao.weibo.users.mapper.UsersMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 *
 * 描述：
 *
 * @author yeyuan
 * @date 2021/08/12 16:45
 **/
@Service
public class UsersDaoImpl implements UsersDao {
    @Resource
    private UsersMapper usersMapper;

    @Override
    public Long insert(Users users) {
        Preconditions.checkNotNull(users);
        users.checkBeforeInsert();
        usersMapper.insertSelective(users);
        return users.getUserId();
    }

    @Override
    public Integer update(Users users, UsersExample example) {
        users.checkBeforeUpdate();
        return usersMapper.updateByExampleSelective(users, example);
    }

    @Override
    public List<Users> find(UsersExample example) {
        return usersMapper.selectByExample(example);
    }

    @Override
    public Integer count(UsersExample example) {
        return usersMapper.countByExample(example);
    }

    private void addCookieToUser(Users users){

    }
}